{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e09ef6c1-00b1-4b7d-b525-0651ab347344",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/letter-combinations-of-a-phone-number\n",
    "\n",
    "\n",
    "Runtime: 0 ms, faster than 100.00% of Go online submissions for Letter Combinations of a Phone Number.\n",
    "Memory Usage: 2.1 MB, less than 21.65% of Go online submissions for Letter Combinations of a Phone Number.\n",
    "\n",
    "\n",
    "```go\n",
    "package main\n",
    "\n",
    "func split_string_to_alphabet_list(s string) []string {\n",
    "\talphabet_list := make([]string, 0)\n",
    "\tfor _, char := range s {\n",
    "\t\tchar_str := string(char)\n",
    "\t\talphabet_list = append(alphabet_list, char_str)\n",
    "\t}\n",
    "\treturn alphabet_list\n",
    "}\n",
    "\n",
    "var possible_set_list = make([][]string, 0)\n",
    "var length = 1\n",
    "\n",
    "func loop(index int, result []string) []string {\n",
    "\tif index == 0 && len(result) == 0 {\n",
    "\t\treturn loop(index+1, possible_set_list[index])\n",
    "\t} else if len(result) == length {\n",
    "\t\treturn result\n",
    "\t}\n",
    "\n",
    "\tnew_list := make([]string, 0)\n",
    "\tfor _, num1 := range result {\n",
    "\t\tfor _, num2 := range possible_set_list[index] {\n",
    "\t\t\tnew_list = append(new_list, num1+num2)\n",
    "\t\t}\n",
    "\t}\n",
    "\treturn loop(index+1, new_list)\n",
    "}\n",
    "\n",
    "func letterCombinations(digits string) []string {\n",
    "\t//8:48\n",
    "    possible_set_list = make([][]string, 0)\n",
    "    length = 1\n",
    "\tresult_list := make([]string, 0)\n",
    "    \n",
    "    if digits == \"\" {\n",
    "        return result_list\n",
    "    }\n",
    "    \n",
    "\tnum_to_abc_map := map[string]string{\n",
    "\t\t\"2\": \"abc\",\n",
    "\t\t\"3\": \"def\",\n",
    "\t\t\"4\": \"ghi\",\n",
    "\t\t\"5\": \"jkl\",\n",
    "\t\t\"6\": \"mno\",\n",
    "\t\t\"7\": \"pqrs\",\n",
    "\t\t\"8\": \"tuv\",\n",
    "\t\t\"9\": \"wxyz\",\n",
    "\t}\n",
    "\n",
    "\tfor _, char := range digits {\n",
    "\t\tchar_str := string(char)\n",
    "\t\talphabet_list := split_string_to_alphabet_list(num_to_abc_map[char_str])\n",
    "\t\tpossible_set_list = append(possible_set_list, alphabet_list)\n",
    "\n",
    "\t\tlength = length * len(alphabet_list)\n",
    "\t}\n",
    "\n",
    "\treturn loop(0, result_list)\n",
    "\t//9:11\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "02f32a2b-c919-4492-b37a-29d16691756e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.14.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
